"""
Case Type   : 系统视图
Case Name   : 测试新增系统视图，sever_principals字段与数据类型
Create At   : 2025-11-18
Owner       : lvlintao666
Description :
    1.查看系统视图sever_principals的结构
    2.该视图字段与对应字段数据类型是否正确
Expect      :
    1.查看系统视图sever_principals的结构成功
    2.该视图字段与字段数据类型对应正确
History     :
"""

import sys
import unittest
from yat.test import Node
from yat.test import macro

sys.path.append(sys.path[0] + "/../")
from testcase.utils.Logger import Logger
from testcase.utils.Common import Common
from testcase.utils.CommonSH import CommonSH

logger = Logger()

class IndexFileDamaged(unittest.TestCase):
    def setUp(self):
        logger.info('----------------this is setup-----------------------')
        logger.info('--------------OpenGauss_Compatibility_D_View_Principals_Case0001开始执行--------------')
        self.com = Common()
        self.comsh = CommonSH('PrimaryDbDmode')
        self.expect_result_dict = {
            'Column': ['name','principal_id','sid','type','type_desc','is_disbaled','create_date',
                       'modify_date','default_database_name','default_language_name','creadential_id',
                       'owning_principal_id','is_fixed_role'],
            'Type': ['name','integer','varbinary(85)','character(1)','nvarchar2(60)','integer',
                     'timestamp without time zone','timestamp without time zone','name',
                     'name','integer','integer','integer']}

    def test_Index_file_damaged(self):
        logger.info('----------------------------查看表结构-----------------------------')
        msg = self.comsh.execut_db_sql('\d server_principals')
        logger.info(msg)
        result_dict = self.com.format_sql_result(msg)
        logger.info(result_dict)
        del result_dict['Modifiers']
        self.assertDictEqual(self.expect_result_dict, result_dict)

    def tearDown(self):
        logger.info('----------------this is tearDown-----------------------')
        # 无须清理环境
        logger.info('-----------------------OpenGauss_Compatibility_D_View_Principals_Case0001执行完成-----------------------------')



